#include "time.h"
#include <iostream>

Time::Time(){
	hour = 0;
	min = 0;
	sec = 0;
}

Time::Time(int aHour, int aMin, int aSec){
	hour = aHour;
	min = aMin;
	sec = aSec;
}

int Time::getHour() const {
	return hour;
}

int Time::getMin() const {
	return min;
}

int Time::getSec() const {
	return sec;
}

void Time::printAmPm() const {
	int min0 = min % 10;
	int sec0 = sec % 10;
	int min1 = min / 10;
	int sec1 = sec / 10;
	if( hour < 13 )
		std::cout << hour << ':' << min1 << min0 << '.' << sec1 << sec0 << " am" << std::endl;
	else
		std::cout << hour - 12 << ':' << min1 << min0 << '.' << sec1 << sec0 << " pm" << std::endl;
}

void Time::setHour(int aHour){
	hour = aHour;
}

void Time::setMin(int aMin){
	min = aMin;
}

void Time::setSec(int aSec){
	sec = aSec;
}

bool IsEarlierThan( const Time & t1, const Time & t2 ){
	int time1 = t1.getHour();
	time1 = time1 * 60 + t1.getMin();
	time1 = time1 * 60 + t1.getSec();
	int time2 = t2.getHour();
	time2 = time2 * 60 + t2.getMin();
	time2 = time2 * 60 + t2.getSec();
	if(time1 < time2)
		return true;
	return false;
}
